<?php


use Biz\cache\lottery\CCreateWikiList;
use Biz\service\activity\CreateWikiList;

ini_set('display_errors', 1);
error_reporting(-1);
require_once '/data/wwwroot/g_vendor/autoload.php';


echo <<<CODE
======== 参数列表 =========
prepareGuidance 初始化主题信息
clearGiftPool 清空奖池
watchGiftPool 查看奖池
allRank 查看主题榜单
log 查看日志
monitoring 监控日志
uid {uid} 用户信息
clearAllCache 清空所有缓存
activityLiving 活动时间
reset 重置活动数据
======== end =========
CODE, PHP_EOL;

$action = $argv[1] ?? '';


switch ($action) {
    case 'reset':
        CreateWikiList::getInstance()->reset();
        break;
    case 'uid':
        $uid = $argv[2] ?? 0;
        var_dump(CreateWikiList::getInstance($uid)->userCache());
        break;
    case 'prepareGuidance':
        CreateWikiList::prepareGuidance();
        break;
    case 'clearGiftPool':
        CCreateWikiList::clearGiftPool();
        break;
    case 'watchGiftPool':
        echo implode(',', CCreateWikiList::getGiftPool());
        break;
    case 'allRank':
        foreach (CCreateWikiList::getAllRank([1, 2, 3, 4, 5, 6, 7]) as $topic_id => $ids) {
            echo "主题: [$topic_id] 排序:", json_encode($ids), PHP_EOL;
        }
        break;
    case 'log':
        var_dump(CCreateWikiList::allLog());
        break;
    case 'monitoring':
        CreateWikiList::getInstance()->monitoring();
        break;
    case 'clearAllCache':
        CreateWikiList::getInstance()->clearAllCache();
        break;
    case 'activityLiving':
        echo "当前日期:", CreateWikiList::getInstance()->getDate(), PHP_EOL;
        echo "活动结束日期:", CreateWikiList::getInstance()->getActivityEndDate(), PHP_EOL;
        echo "当前状态:", CreateWikiList::getInstance()->activityLiving() ? '进行中' : '已结束', PHP_EOL;
        break;

}

